package com.ymatou.iapi.userservice.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.userservice.parameter.req.CreateUserReq;
import com.ymatou.iapi.userservice.parameter.req.SetUserLogoReq;
import com.ymatou.iapi.userservice.service.SetUserLogoCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.JUserCallService;
import com.ymttest.database.model.Userinfo;
import com.ymttest.database.model.Userinfoex;
import com.ymttest.database.sqlwapper.JUserWapper;
import com.ymttest.utils.TestDataManager;
/**
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_SetUserLogo{
	private static SetUserLogoReq SetUserLogoBean;
	private static SetUserLogoCall SetUserLogoCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("设置头像");
	}

	@Before
	public void caseUp() {
		SetUserLogoBean=new SetUserLogoReq();
		SetUserLogoCall=new SetUserLogoCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(SetUserLogoCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SetUserLogo_001() {
		Logger.start(true,"设置头像,成功");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			Integer uid = JUserCallService.createUserCall(cur);
			
			SetUserLogoBean.setUserId(uid);
			SetUserLogoBean.setLogoUrl("http://www.ymatou.com");
			SetUserLogoCall.setData(SetUserLogoBean);
			SetUserLogoCall.callService();		
			Logger.verifyEquals("true", SetUserLogoCall.getString("Success"), "验证Success");
			Logger.verifyEquals("200", SetUserLogoCall.getString("ResponseCode"), "验证ResponseCode");
			Userinfoex info = new JUserWapper().selectUserinfoexByUid(uid).get(0);
			Logger.verifyEquals(info.getLogoUrl(), SetUserLogoBean.getLogoUrl(), "验证LogoUrl");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_SetUserLogo_002() {
		Logger.start(false,"不输入uid,失败");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			Integer uid = JUserCallService.createUserCall(cur);
			
//			SetUserLogoBean.setUserId(uid);
			SetUserLogoBean.setLogoUrl("http://www.ymatou.com");
			SetUserLogoCall.setData(SetUserLogoBean);
			SetUserLogoCall.callService();		
			Logger.verifyEquals("false", SetUserLogoCall.getString("Success"), "验证Success");
			Logger.verifyEquals("100", SetUserLogoCall.getString("ResponseCode"), "验证ResponseCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_SetUserLogo_003() {
		Logger.start(false,"不输入LogoUrl,失败");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			Integer uid = JUserCallService.createUserCall(cur);
			
			SetUserLogoBean.setUserId(uid);
//			SetUserLogoBean.setLogoUrl("http://www.ymatou.com");
			SetUserLogoCall.setData(SetUserLogoBean);
			SetUserLogoCall.callService();		
			Logger.verifyEquals("false", SetUserLogoCall.getString("Success"), "验证Success");
			Logger.verifyEquals("100", SetUserLogoCall.getString("ResponseCode"), "验证ResponseCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
		@Test
		@Category({P3.class})
		@TestCase
		public void Tc_SetUserLogo_004() {
			Logger.start(true,"重复修改LogoUrl,成功");
			try {
				CreateUserReq cur = new CreateUserReq();
				cur = JUserCallService.initCreateUserBean(cur);
				Integer uid = JUserCallService.createUserCall(cur);
				
				SetUserLogoBean.setUserId(uid);
				SetUserLogoBean.setLogoUrl("http://www.ymatou.com");
				SetUserLogoCall.setData(SetUserLogoBean);
				SetUserLogoCall.callService();
				
				SetUserLogoBean.setLogoUrl("http://www.ymatou.com/update");
				SetUserLogoCall.callService();
				
				Logger.verifyEquals("true", SetUserLogoCall.getString("Success"), "验证Success");
				Logger.verifyEquals("200", SetUserLogoCall.getString("ResponseCode"), "验证ResponseCode");
				Userinfoex info = new JUserWapper().selectUserinfoexByUid(uid).get(0);
				Logger.verifyEquals(info.getLogoUrl(), SetUserLogoBean.getLogoUrl(), "验证LogoUrl");
			} catch (Exception e) {
				Logger.fail(e);
			}
	}
}